@extends('layout')
@section('content')
    <div class="page-container">
        @if (count($errors) > 0)
            <div class="alert alert-danger">
                <strong>新增失败</strong> 输入不符合要求<br><br>
                {!! implode('<br>', $errors->all()) !!}
            </div>
        @endif
        <form action="{{ url('menu') }}" method="post" class="form form-horizontal" id="menu-add" onsubmit="return false">
            {{ csrf_field() }}
            <div class="row cl">
                <label for="" class="form-label col-xs-4 col-sm-3 text-r">菜单名:</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" autocomplete="off"
                           placeholder="菜单名" name="name" datatype="*" dragonfly="true" nullmsg="菜单名不能为空！">
                </div>
            </div>

            <div class="row cl">
                <label for="" class="form-label col-xs-4 col-sm-3 text-r">URL地址:</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" autocomplete="off"
                           placeholder="URL地址" name="url" datatype="*" dragonfly="true" nullmsg="URL地址不能为空！">
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input type="submit" class="btn btn-primary radius" value="提交">
                </div>
            </div>
        </form>
    </div>
@endsection
@section('script')
    <script type="text/javascript" src="{{ asset('H_uiv_3.0/lib/My97DatePicker/4.8/WdatePicker.js') }}"></script>
    <script type="text/javascript" src="{{ asset('H_uiv_3.0/lib/jquery.validation/1.14.0/jquery.validate.js') }}"></script>
    <script type="text/javascript" src="{{ asset('H_uiv_3.0/lib/jquery.validation/1.14.0/validate-methods.js') }}"></script>
    <script type="text/javascript" src="{{ asset('H_uiv_3.0/lib/jquery.validation/1.14.0/messages_zh.js') }}"></script>
    <script>
        $(function () {
            $("#menu-add").validate({
                rules:{

                },
                onkeyup:false,
                focusCleanup:true,
                success:"valid",
                submitHandler:function(form){
                    $(form).ajaxSubmit();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$('.btn-refresh').click();
                    parent.layer.close(index);
                }
            });
        })
    </script>
@endsection